package com.jack.xiaoer.dto;

import com.jack.xiaoer.constant.MyConstant;
import com.jack.xiaoer.validator.Groups;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;


/**
 * Created by Jackaroo Zhang on 2018/12/19.
 */
public class CartDTO extends BaseDTO {

    private Long id;

    @NotNull(message = "商家ID不能为空", groups = {Groups.CartCreat.class, Groups.OrderCreate.class})
    private Long shopId;

    @NotNull(message = "用户ID不能为空", groups = {Groups.CartCreat.class, Groups.OrderCreate.class})
    private Long userId;

    @NotNull(message = "商品ID不能为空", groups = {Groups.CartCreat.class})
    private Long productId;

    @NotNull(message = "商品数量不能为空", groups = {Groups.CartCreat.class})
    @Range(min = 0, max = 100, message = "商品数量必须在0~100之间", groups = {Groups.CartCreat.class})
    private Integer productCount;

    private String property;

    private Integer checked;

    @Override
    public String toString() {
        return "CartDTO{" +
                "id=" + id +
                ", shopId=" + shopId +
                ", userId=" + userId +
                ", productId=" + productId +
                ", productCount=" + productCount +
                ", property='" + property + '\'' +
                ", checked=" + checked +
                '}';
    }

    public boolean checked() {
        return this.checked == MyConstant.CHECKED;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Integer getProductCount() {
        return productCount;
    }

    public void setProductCount(Integer productCount) {
        this.productCount = productCount;
    }

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public Integer getChecked() {
        return checked;
    }

    public void setChecked(Integer checked) {
        this.checked = checked;
    }
}
